#!/usr/bin/env python3
"""
简化版打包脚本
"""

import os
import sys
import subprocess

def main():
    print("=== AutoGUI 简化打包 ===")
    
    # 检查PyInstaller
    try:
        import PyInstaller
        print(f"PyInstaller 版本: {PyInstaller.__version__}")
    except ImportError:
        print("安装 PyInstaller...")
        subprocess.check_call([sys.executable, "-m", "pip", "install", "pyinstaller"])
    
    # 构建命令
    cmd = [
        sys.executable, "-m", "PyInstaller",
        "--onefile",                    # 单文件模式
        "--windowed",                   # 无控制台窗口
        "--name=AutoGUI",               # 输出文件名
        "--add-data=config;config",     # 添加配置文件夹
        "--add-data=fonts;fonts",       # 添加字体文件夹
        "--add-data=SIMION;SIMION",     # 添加SIMION文件夹
        "--add-data=store;store",       # 添加store文件夹
        "--add-data=utils;utils",       # 添加utils文件夹
        "--add-data=windows;windows",   # 添加windows文件夹
        "--add-data=scripts;scripts",   # 添加scripts文件夹
        "--hidden-import=tkinter",
        "--hidden-import=numpy",
        "--hidden-import=openpyxl",
        "--hidden-import=psutil",
        "--hidden-import=pyautogui",
        "--hidden-import=cv2",
        "--hidden-import=PIL",
        "main.py"
    ]
    
    print("开始打包...")
    try:
        subprocess.check_call(cmd)
        print("打包成功！")
        print("可执行文件: dist/AutoGUI.exe")
    except subprocess.CalledProcessError as e:
        print(f"打包失败: {e}")

if __name__ == "__main__":
    main()
